// JavaScript Document
String.prototype.replaceAll = function(strTarget, strSubString){
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );
	while (intIndexOfMatch != -1){
		strText = strText.replace(strTarget, strSubString)
		intIndexOfMatch = strText.indexOf(strTarget);
	}
	return( strText );
}
function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ '=' +escape(value)+
    ((expiredays==null) ? '' : ';expires='+exdate.toGMTString());
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + '=');
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(';',c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return '';
}
jQuery.fn.exists = function () {
    return jQuery(this).length !== 0;
}
function clearForm(oForm) {
	  var elements = oForm.elements; 
	  oForm.reset();
	  for(i=0; i<elements.length; i++) {
		field_type = elements[i].type.toLowerCase();
		switch(field_type) {
			case "text": 
			case "password": 
			case "textarea":
		        case "hidden":	
		        	elements[i].value = ""; 
				break;
			case "radio":
			case "checkbox":
	  			if (elements[i].checked) {
	   				elements[i].checked = false; 
				}
				break;
			case "select-one":
			case "select-multi":
	            	elements[i].selectedIndex = -1;
				break;
			default: 
				break;
		}
	}
}
function setupAjax(boxId)
{
	jQuery("#" + boxId).ajaxStart(function(){
	      jQuery(this).fadeIn();
	});
	jQuery("#" + boxId).ajaxSuccess(function(evt, request, settings){
	      jQuery(this).fadeOut();
	});
}

